import Vue from 'vue'
import VueRouter from 'vue-router'
import Cart from '../views/Cart.vue'
import Category from '../views/Category.vue'
import Mine from '../views/Mine.vue'
import GoodsList from '../views/GoodsList.vue'
import Layout from '../Layout.vue';
import Login from '../views/Login.vue'
import Register from '../views/Register.vue'


Vue.use(VueRouter);


const routes = [
  {
    path: '/',
    name: 'Layout',
    component: Layout, //整个app的容器
    children: [
      {
        path: '',
        redirect: '/category', // 重定向
      },
      {
        path: 'category',
        component: Category,
        children: [
          {
            path: 'goods-list',
            component: GoodsList
          }
        ]
      },
      {
        path: 'cart',
        component: Cart
      },
      {
        path: 'mine',
        component: Mine
      }
    ]
  },

  //登录
  {
    path: '/login',
    component: Login
  },
  //注册
  {
    path: '/register',
    component: Register
  }

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
